#ifndef PACKET_H
#define PACKET_H
namespace yssdk
{
#pragma pack(1)
    struct Message
    {
                int  head;
                Message()
                {
                    head=0x0009;
                }
                int                Messagesize;
                int                MessageID;
    };
#pragma pack()
    struct Packet
    {
        int         uid;
        Message *msg;
    };
}

class netstream
{
    public:
    netstream(int maxlenth)
    {
        this->maxlenth=maxlenth;
        stream=new unsigned char[ this->maxlenth];
        memset(stream,0,this->maxlenth);
         streamreadpoint=0;
         streamsize=0;
         streamwritepoint=0;
    }
    ~netstream()
    {
        delete[] stream;
    }
    void    write(unsigned char* data,int length)
    {
        memcpy(stream+streamwritepoint,data,length);
        streamsize+=length;
        streamwritepoint+=length;
    }
    void Read(unsigned char* data,int length)
    {
        memcpy (data,stream+streamreadpoint,length);
        streamreadpoint+= length;
         streamsize-= length;
    }
   unsigned char * GetStreamPoint()
   {
       return &stream[streamreadpoint];
   }
    void setreadpoint(int i)
    {
        streamreadpoint=i;
    }
    void setwritepoint(int i)
    {
        streamwritepoint=i;
    }
    void setstreamsize(int i)
    {
        streamsize=i;
    }
    int  GetReadPointinteger()
    {
            return streamreadpoint;
    }
    int  GetStreamSizeinteger()
    {
            return streamsize;
    }
    int  GetWritePointinteger()
    {
            return streamwritepoint;
    }
 private:
    unsigned char *stream;
    int streamreadpoint;
    int streamsize;
     int streamwritepoint;
     int maxlenth;
};
#endif // PACKET_H
